<?php
	function chuyenTrang($url){
		echo "<html><script>";
        echo "document.location='".$url."';";
        echo "</script></html>";
	}
	$data = array();
	function addData($tenLC, $tongTG, $o_n, $Km, $s4, $s7,$s16, $s25, $s35, $s45){
		global $data;
		$data[] = array(
					"tenLC" => $tenLC,
					"tongTG" => $tongTG,
					"o_n" => $o_n,
					"Km" => $Km,
					"s4" => $s4,
					"s7" => $s7,
					"s16" => $s16,
					"s25" => $s25,
					"s35" => $s35,
					"s45" => $s45
				);
	}
	
	$GLOBAL_VALUE = array();	
	function setValues($val_1, $val_2, $val_3, $val_4){
		global $GLOBAL_VALUE;
		
		$GLOBAL_VALUE[] = array(
							"maLC"=> $val_1,
							"maCT"=> $val_2,
							"month"=> $val_3,
							"year"=> $val_4
							);
	}
	
	function getValues(){
		global $GLOBAL_VALUE;
		return $GLOBAL_VALUE;
	}
	
	function convertDate($date){
		$day = substr($date, 8, 2);
		$month = substr($date, 5, 2);
		$year = substr($date, 0, 4);
		return ($date!="")?$day."/".$month."/".$year:"Chưa có";
	}
	function convertYMD($ngayKH)
        {
                $day = substr($ngayKH, 3, 2);
		$month = substr($ngayKH, 0, 2);
		$year = substr($ngayKH, 6, 4);
		return ($ngayKH!="")?$year."-".$month."-".$day:"";
        }
        function convertSearch($ngayKH)
        {
                $day = substr($ngayKH, 0, 2);
		$month = substr($ngayKH, 3, 2);
		$year = substr($ngayKH, 6, 4);
		return ($ngayKH!="")?$year."-".$month."-".$day:"";
        }
        function convertMDY($ngayKH)
        {
                $day = substr($ngayKH, 8, 2);
		$month = substr($ngayKH, 5, 2);
		$year = substr($ngayKH, 0, 4);
		return ($ngayKH!="")?$month."/".$day."/".$year:"";
        }
	function subDateFrom($ngayKH, $ngayKT){
		$value[0] = substr($ngayKH, 3, 2);
		$value[1] = substr($ngayKH, 0, 2);
		$value[2] = substr($ngayKH, 6, 4);
		$value[3] = substr($ngayKT, 3, 2);
		$value[4] = substr($ngayKT, 0, 2);
		$value[5] = substr($ngayKT, 6, 4);
		return $value;
	}
	
	function validDate($month, $day, $year){
		return checkdate($month, $day, $year);
	}
	
	function numOfDate($value){
		$toDate = mktime(0,0,0,$value[4], $value[3], $value[5]);
		$fromDate= mktime(0,0,0,$value[1], $value[0], $value[2]);
		$result = $toDate - $fromDate;
		return $result/(24*60*60);
	}
	
	function convertExcelDate($date){
		return substr($date, 0, 4)."-".substr($date, 5, 2)."-".substr($date, 8, 2)."T00:00:00.000";
	}
?>